def str_crud():
    str1 = 'a'
    str2 = 'b'
    str3 = 'ab cd ef g'

    print("str1 + str2 = {}".format(str1 + str2))
    str4 = str3.replace(' ', '')
    print(f"str3去重空格为：{str4}")
    print(f"str4取前 4 位：{str4[:4]}")
    print(f"str4取后 4 位：{str4[3:]}")
    print(f"str4取中间 3 位：{str4[2:5]}")
    print(f"str4倒序：{str4[::-1]}")

    list1 = str3.split(' ')
    print(list1)
    str5 = '-'.join(list1)
    print(str5)


def save_file():
    with open('./demo_0202_tmp.py', 'r') as f:
        text_str = f.read()
    print(text_str)
    with open('./demo_0202.py', 'w') as f:
        f.write(text_str)


if __name__ == '__main__':
    str_crud()
    save_file()
